<template>
  <div class="page">
    <planning-create-index form-type="edit" />
  </div>
</template>

<script>
import PlanningCreateIndex from "./compontents/PlanningCreateIndex.vue";
import { Message } from "element-ui";
import { postRequest } from "@/api/api";
import { getRequest } from "@/api/api";
import store from "../../store";
export default {
  components: { PlanningCreateIndex },
  beforeRouteEnter(to, from, next) {
    postRequest("/plan/plan_detail", to.params).then((res) => {
      let records = res.data.data;
      let user = store.getters.loginUser.data;
      let roles = store.getters.roles;
      console.log("user", user);
      console.log("roles", roles);
      console.log(
        records.createId,
        records.project_leader,
        records.project_director
      );
      if (
        user.username === records.project_leader ||
        roles.includes("科室主任") ||
        user.id == records.createId
      ) {
        next();
      } else {
        Message.error("没有权限编辑这份文档")
      }
    });
  },
  methods: {
    postPlanning(params) {
      // console.log("this.formDataMap:", this.formDataMap);
    },
  },
};
</script>

<style scoped>
.page {
  position: relative;
  width: 99%;
}
</style>